<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<%@ include file="/common/include.jsp"%>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<title>
		<c:set var="titleKey"><tiles:getAsString name="title" ignore="true" /></c:set> 
		<fmt:message key="${titleKey}" />
	</title>
	<link rel="stylesheet" type="text/css" href="<c:url value='/styles/default.css'/>" media="screen"/>
	<script type="text/javascript" src="<c:url value='/scripts/jquery/jquery-1.4.2.js'/>"></script>
	<script type="text/javascript" src="<c:url value='/scripts/jquery/jquery.multiselects.js'/>"></script>
    <script type="text/javascript" src="<c:url value='/scripts/jquery/jquery.metadata.js'/>"></script>
    <script type="text/javascript" src="<c:url value='/scripts/jquery/jquery.tablesorter.js'/>"></script>
    <script type="text/javascript" src="<c:url value='/scripts/jquery/jquery.dimensions.js'/>"></script>
    <script type="text/javascript" src="<c:url value='/scripts/jquery/jquery.form.js'/>"></script>
    <script type="text/javascript" src="<c:url value='/scripts/jquery/jquery.highlight-1.1.source.js'/>"></script>
    <script type="text/javascript" src="<c:url value='/scripts/sns.js'/>"></script>
    <script type="text/javascript" src="<c:url value='/scripts/global.js'/>" ></script>
    <script type="text/javascript" src="<c:url value='/scripts/sdmenu.js'/>" ></script>
<script type="text/javascript">

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

function addClass(element,value) {
  if (!element.className) {
    element.className = value;
  } else {
    newClassName = element.className;
    newClassName+= " ";
    newClassName+= value;
    element.className = newClassName;
  }
}


function stripeTables() {
	var tables = document.getElementsByTagName("table");
	for (var m=0; m<tables.length; m++) {
		if (tables[m].className == "pub_list01") {
			var tbodies = tables[m].getElementsByTagName("tbody");
			for (var i=0; i<tbodies.length; i++) {
				var odd = true;
				var rows = tbodies[i].getElementsByTagName("tr");
				for (var j=0; j<rows.length; j++) {
					if (odd == false) {
						odd = true;
					} else {
						addClass(rows[j],"odd");
						odd = false;
					}
				}
			}
		}
	}
}
function highlightRows() {
  if(!document.getElementsByTagName) return false;
  	var tables = document.getElementsByTagName("table");
	for (var m=0; m<tables.length; m++) {
		if (tables[m].className == "pub_list01") {
			  var tbodies = tables[m].getElementsByTagName("tbody");
			  for (var j=0; j<tbodies.length; j++) {
				 var rows = tbodies[j].getElementsByTagName("tr");
				 for (var i=0; i<rows.length; i++) {
					   rows[i].oldClassName = rows[i].className
					   rows[i].onmouseover = function() {
						  if( this.className.indexOf("selected") == -1)
							 addClass(this,"highlight");
					   }
					   rows[i].onmouseout = function() {
						  if( this.className.indexOf("selected") == -1)
							 this.className = this.oldClassName
					   }
				 }
			  }
		}
	}
}

function selectRowCheckbox(row) {
	var checkbox = row.getElementsByTagName("input")[0];
	if (checkbox.checked == true) {
		checkbox.checked = false;
	} else
	if (checkbox.checked == false) {
		checkbox.checked = true;
	}
}

function lockRow() {
  	var tables = document.getElementsByTagName("table");
	for (var m=0; m<tables.length; m++) {
		if (tables[m].className == "pub_list01") {
				var tbodies = tables[m].getElementsByTagName("tbody");
				for (var j=0; j<tbodies.length; j++) {
					var rows = tbodies[j].getElementsByTagName("tr");
					for (var i=0; i<rows.length; i++) {
						rows[i].oldClassName = rows[i].className;
						rows[i].onclick = function() {
							if (this.className.indexOf("selected") != -1) {
								this.className = this.oldClassName;
							} else {
								addClass(this,"selected");
							}
							selectRowCheckbox(this);
						}
					}
				}
		}
	}
}

addLoadEvent(stripeTables);
addLoadEvent(highlightRows);
addLoadEvent(lockRow);


function lockRowUsingCheckbox() {
	var tables = document.getElementsByTagName("table");
	for (var m=0; m<tables.length; m++) {
		if (tables[m].className == "pub_list01") {
			var tbodies = tables[m].getElementsByTagName("tbody");
			for (var j=0; j<tbodies.length; j++) {
				var checkboxes = tbodies[j].getElementsByTagName("input");
				for (var i=0; i<checkboxes.length; i++) {
					checkboxes[i].onclick = function(evt) {
						if (this.parentNode.parentNode.className.indexOf("selected") != -1){
							this.parentNode.parentNode.className = this.parentNode.parentNode.oldClassName;
						} else {
							addClass(this.parentNode.parentNode,"selected");
						}
						if (window.event && !window.event.cancelBubble) {
							window.event.cancelBubble = "true";
						} else {
							evt.stopPropagation();
						}
					}
				}
			}
		}
	}
}
addLoadEvent(lockRowUsingCheckbox);
</script>
</head>
<body>
	<div class="container">
		<div class="header">
			<tiles:insertAttribute	name="html.admin.mainHeader" />
		</div>
		<div class="main">
			<div class="sidenav">
				<div class="left_articles">
					<tiles:insertAttribute name="html.admin.manager" />
				</div>
				<div style="float: left" id="my_menu" class="sdmenu">
					<!-- begin nav -->
					<tiles:insertAttribute name="html.admin.navigation" />
					<!-- end nav -->
				</div>
			</div>
			<div class="content">
				<tiles:insertAttribute name="html.admin.mainBody" />
			</div>
			<div class="clearer"><span></span></div>
		</div>
	</div>
	<div class="footer">
		<tiles:insertAttribute	name="html.admin.mainFooter" />
	</div>
</body>
</html>
